<%@ page language="java" pageEncoding="UTF-8" buffer="128kb"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ include file="/pages/safeai/jsp/common/taglibs.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<%@ include file="/pages/safeai/jsp/common/meta.jsp"%>
		<title>收藏夹</title>
		<link href="${ctx}/css/style.css" rel="stylesheet" type="text/css" /> 
		        
		<script language="JavaScript" src="${ctx}/js/filter.js"></script>
		<script language="JavaScript" src="${ctx}/js/json2.js"></script>
		<script language="JavaScript">
			if(typeof getElementsByName == 'undefined'){
				document.getElementsByName = function(str){
					var s = new Array;
					var b = document.getElementsByTagName('input');
					for(var i=0;i<b.length;i++){
						if(b[i].getAttribute('name') == str) s.push(b[i]);
					}
					return s;
				}
			}
		
			function deleteM(){
				    if(confirm("你确要删除这些收藏？")){ 
				         var hre = "${ctx}/front/favorite.do?method=delFavorite&pid=";
				    	 var fids = document.getElementsByName("dtagfid");
						 var checkArr = document.getElementsByName("checkboxs");
						 var isc = false;
						
						 for(var i=0;i<fids.length;i++){
						 	if(checkArr[i].checked == true){
						 		 hre = hre+ fids[i].value +",";
						 		 isc = true;
						 	} 
						 }
						
						if(isc){
							location.href = hre; 
						}else{
							alert("请先选择一条记录");
						} 
				        return true;
				    } else{ 
				        return false;
				    }
			}
			function buyM(){
		         var hre = "${ctx}/shopping/addToShoppingCart.do?m=addProductForward";
		    	 var fids = document.getElementsByName("tagfid");
				 var checkArr = document.getElementsByName("checkboxs");
				 var isc = false;
				 
				 var pid = "&productId=";
				 var fid = "&fid=";
				 
				 for(var i=0;i<fids.length;i++){
				 	if(checkArr[i].checked == true){
				 		 pid = pid+ fids[i].value +",";
				 		 fid = fid+ fids[i].value +","; 
				 		 isc = true;
				 	} 
				 } 
		 
				 hre = hre+pid+fid;
				 
				if(isc){
					location.href = hre; 
				}else{
					alert("请先选择一条记录");
				}
				 
			}
		    function count() {
				 var checkArr = document.getElementsByName("checkboxs");
				 var selectCount = 0;
				 var priceCount = 0;
				 for(var i=0;i<checkArr.length;i++){
				 	if(checkArr[i].checked == true){
				 		 priceCount = priceCount + checkArr[i].value*1;
				 		 selectCount += 1;
				 	} 
				 }
				 document.getElementById("count1").innerHTML = selectCount;
				 document.getElementById("sunPrice1").innerHTML = priceCount;
				 
				 document.getElementById("count2").innerHTML = selectCount;
				 document.getElementById("sunPrice2").innerHTML = priceCount;
			} 
			function gotoPage(pageOffset, pageSize) {
				var form = document.getElementsByTagName("form")[1];
				form.elements["pager.offset"].value = pageOffset;
				form.elements["pageSize"].value = pageSize;
				form.submit();
			}
			function selectAll(all) {
				 var checkArr = document.getElementsByName("checkboxs");
				 for(var i=0;i<checkArr.length;i++){
				 	if(all.checked==true){
				 		checkArr[i].checked = true;
				 	}else{
				 		checkArr[i].checked = false;
				 	}
				 }
				 
				 count();
			} 
		</script>
	</head>
<body>
<div class="bg">
		  <div class="bg_inside">
		<div class="head">
			<c:import url="/pages/safeai/jsp/shop/header.jsp"></c:import>
		</div>
<c:import url="/front/userinfo.do?method=myRayi"></c:import>

<form action="${ctx}/front/favorite.do?method=queryFavorite" name="favoriteForm" method="post">
<div class="user_order_content">
<div  class="user_order_content_top"><img src="../images/user_order_content_top.jpg" /></div>
<div class="user_order_content_center"><ul><li style=" background-image:url(../images/title_letter_icon.jpg); background-position:left center; background-repeat:no-repeat;padding:5px 0px 0px 15px;margin-bottom:5px;line-height:15px;color:#5a3e2e">收藏夹</li>
<li>您的收藏夹共有：<font class="orange">${Page.totalSize }</font>件商品</li>
<li>排序方式：
<label>
<select name="fav.orderby" onchange="javascript:document.favoriteForm.submit();">
<option value="1" <logic:equal value="1" name="favorite" property="orderby">selected</logic:equal>>时间排序</option>
<option value="2" <logic:equal value="2" name="favorite" property="orderby">selected</logic:equal>>从高到低</option>
<option value="3" <logic:equal value="3" name="favorite" property="orderby">selected</logic:equal>>从低到高</option>
</select>
</label>
</li>
<logic:empty name="FavoriteRange" property="records">
<li>您目前还没有收藏!</li>
</logic:empty>
<logic:notEmpty name="FavoriteRange" property="records">
<li><span style="width:300px;float:left;padding:0;margin:0px;text-align:left;border:0px">您供选择了<font class="orange"><label id="count1">0</label></font>件商品，金额总计：<font class="orange"><label id="sunPrice1">0</label></font> 元</span><span style="width:300px;float:right;padding:0;margin:0px;text-align:right;border:0px"><a href="#" onclick="buyM();" >购买选中商品</a>│<a href="#" onclick="deleteM();">删除选中商品</a></span></li>

<li style="color:#A6957C; background-color:#efefef">
<span style="width:40px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px;padding-top:5px"><label><input type="checkbox" id="all" onclick="selectAll(this);" /style="border:0px;width:30px;"></label></span>
<span style="width:70px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px">商品图片</span>
<span style="width:270px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px">商品名称</span>
<span style="width:70px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px">放入时间</span>
<span style="width:70px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px">商品单价</span>
<span style="width:70px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px">操作</span>
</li>


<logic:iterate id="favorite" name="FavoriteRange" property="records">
<li style="margin:5px 0px;border-bottom:1px dashed #ddd;padding-bottom:5px">
<span style="width:40px;float:left;padding:0;margin:10px 4px 0px 4px;text-align:center;border:0px;padding-top:5px"><label><input type="checkbox" name="checkboxs" onclick="count();" value="<bean:write name="favorite" property="price" />" /style="border:0px;width:30px;"></label>
</span>
<span style="width:70px;float:left;padding:0;margin:0px 4px;text-align:center;border:0px"><a href="${ctx }/product/productMessage.do?method=shopDeatails&id=${favorite.productId}" style="display:block;width:50px;height:50px;"><img src="${ctx}/product_image/${favorite.productId}_1_50X50.jpg" border="0" style="width:50px;height:50px;" /></a></span>
<span style="width:270px;float:left;padding:0;margin:10px 4px 0px 4px;text-align:center;border:0px;text-overflow : ellipsis ;white-space : nowrap ;overflow:hidden;"><a href="${ctx }/product/productMessage.do?method=shopDeatails&id=${favorite.productId}" class="text_ad"><bean:write name="favorite" property="productName" /></a></span>
<span style="width:70px;float:left;padding:0;margin:10px 4px 0px 4px;text-align:center;border:0px"><bean:write name="favorite" property="createTime" format="yyyy-MM-dd"/></span>
<span style="width:70px;float:left;padding:0;margin:10px 4px 0px 4px;text-align:center;border:0px"><bean:write name="favorite" property="price" /></span>
<span style="width:80px;float:left;padding:0;margin:10px 4px 0px 4px;text-align:center;border:0px"><a href="${ctx}/shopping/viewShoppingCart.do?m=addProductForward&id=${favorite.productId}&fid=${favorite.productId}"><img src="../images/products_addcart.jpg"/border="0" / style="border:0px;padding:0px;margin:0px"></a><br /><a href="#" onclick="if(confirm('是否删除？')==true)location.href='${ctx}/front/favorite.do?method=delFavorite&pid=${favorite.id}'" class="text_ad">删除商品</a></span>
</li>
<input type="hidden" name="tagfid" value="${favorite.productId}" />
<input type="hidden" name="dtagfid" value="${favorite.id}" />
</logic:iterate>

<li><span style="width:300px;float:left;padding:0;margin:0px;text-align:left;border:0px">您供选择了<font class="orange"><label id="count2">0</label></font>件商品，金额总计：<font class="orange"><label id="sunPrice2">0</label></font> 元</span><span style="width:300px;float:right;padding:0;margin:0px;text-align:right;border:0px"><a href="#" onclick="buyM();" >购买选中商品</a>│<a href="#" onclick="deleteM();">删除选中商品</a></span></li>
 
<li style="float:right;text-align:right;margin-top:20px;width:400px"><%@ include file="/user/pageFront1.jsp"%></li>


</ul>
</logic:notEmpty>		   
</div>
<div  class="user_order_content_bottom"><img src="../images/user_order_content_bottom.jpg" /></div>
</div>
</div>

</form>
<%@ include file="/user/commonProblem.jsp"%>
<div class="bottom">
	<%@ include file="/pages/safeai/jsp/shop/bottom.jsp"%>	
	<div class="clearAll"></div>
</div>
</body>
</html>